package com.baoyouqun.controller;

import com.alibaba.cola.dto.Query;
import com.baoyouqun.base.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import com.baoyouqun.entity.VirtualNumber;
import com.baoyouqun.service.VirtualNumberService;
import com.baoyouqun.domain.VO.VirtualNumberVO;
import com.baoyouqun.domain.CreateCmd.VirtualNumberCreateCmd;
import com.baoyouqun.domain.UpdateCmd.VirtualNumberUpdateCmd;
import com.baoyouqun.domain.Query.VirtualNumberQuery;

@RestController
@RequestMapping("/virtualNumber")
@Api(tags = "用户虚拟号码服务信息表管理接口")
public class VirtualNumberController {

    @Resource
    private VirtualNumberService virtualNumberService;

    @PostMapping("create")
    @ApiOperation("新增用户虚拟号码服务信息表")
    public SingleResponse<VirtualNumberVO> create(VirtualNumberCreateCmd cmd) {
        return virtualNumberService.create(cmd);
    }

    @PutMapping("update")
    @ApiOperation("修改用户虚拟号码服务信息表")
    public Response update(VirtualNumberUpdateCmd cmd) {
        return virtualNumberService.update(cmd);
    }

    @DeleteMapping("delete")
    @ApiOperation("根据ID删除用户虚拟号码服务信息表")
    public Response delete(String id) {
    virtualNumberService.removeById(id);
        return Response.buildSuccess();
    }

    @GetMapping("getById")
    @ApiOperation("根据ID查询用户虚拟号码服务信息表")
    public SingleResponse<VirtualNumberVO> selectById(String id) {
        return SingleResponse.of(virtualNumberService.selectById(id));
    }

    @GetMapping("page")
    @ApiOperation("分页查询用户虚拟号码服务信息表")
    public PageResponse<VirtualNumberVO> page(VirtualNumberQuery query) {
        IPage<VirtualNumberVO> page = virtualNumberService.pageVo(query);
        return PageResponse.of(page.getRecords(), page.getTotal(), page.getCurrent(), page.getSize());
    }
}